<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<!-- Root transformation -->
	<xsl:template match="/">
		<html>
			<head>
				<style type="text/css">
					span.desc {
						font-family: arial, verdana, sans-serif;
						color: #000000;
						font-size: 12px;
						font-style: normal;
						font-variant: normal;
						font-weight: normal;
						text-align: left;
						text-decoration: none;
						text-transform: none;
						line-height: 18px;
					}
					span.enf {
						color: #1656E0;
					}
					span, span.plain {
						font-family: georgia, "times new roman", times, serif;
						color: #000000;
						font-size: 14px;
						font-style: normal;
						font-variant: normal;
						font-weight: normal;
						text-align: left;
						text-decoration: none;
						text-transform: none;
						line-height: 18px;
					}
					span.title {
						font-family: georgia, "times new roman", times, serif;
						color: #000000;
						font-size: 14px;
						font-style: normal;
						font-variant: normal;
						font-weight: bold;
						text-align: left;
						text-decoration: none;
						text-transform: none;
						line-height: 18px;
					}
				</style>
				<style type="text/css">
					body {
						margin-bottom: 0px;
						margin-left: 0px;
						margin-right: 0px;
						margin-top: 0px;
					}
					table {
						table-layout: auto;
						border-spacing: 0px;
						border-collapse: collapse;
						margin-top: 7px;
						margin-bottom: 7px;
					}
					th {
						border: 1px solid #666666;
						vertical-align: top;
						padding: 2px 5px 2px 5px;
						background-color: #cccccc;
						text-align: center;
					}
					td {
						border: 1px solid #666666;
						vertical-align: top;
						padding: 2px 5px 2px 5px;
						text-align: center;
					}
					p {
						margin: 0px 0px 0px 0px;
						padding: 0px 0px 0px 0px;
					}
				</style>
				<style type="text/css">
					div#root {
						width: auto;
						clear: both;
					}
					div#top {
						width: auto;
						clear: both;
						margin: 10px 10px 10px 10px;
						padding: 5px 5px 5px 5px;
						border-bottom-style: solid;
						border-bottom-width: 1px;
						border-bottom-color: #000000;
					}
					div#logdata {
						width: auto;
						clear: both;
						margin: 0px 10px 10px 10px;
						padding: 5px 5px 5px 5px;
						border-bottom-style: solid;
						border-bottom-width: 1px;
						border-bottom-color: #666666;
					}
					div#log {
						width: auto;
						clear: both;
						margin: 30px 10px 10px 10px;
						padding: 5px 15px 5px 20px;
					}
					div {
						width: auto;
						clear: both;
					}
				</style>
				<style type="text/css">
					div#element {
						width: auto;
						clear: both;
						margin-bottom: 10px;
					}
					div#elementbody {
						width: auto;
						clear: both;
						padding: 6px 6px 6px 6px;
						background-color: #f5f5f5;
					}
					div#container {
						width: auto;
						clear: both;
						margin: 3px 3px 3px 3px;
						padding: 2px 2px 2px 2px;
					}
					div#titleel {
						width: auto;
						clear: both;
						border-bottom-style: solid;
						border-bottom-width: 1px;
						border-bottom-color: #999999;
						cursor: pointer;
					}
					div#innerelement {
						border: 1px solid #aaaaaa;
						margin-bottom: 5px;
					}
				</style>
				<script type="text/javascript">
					function showHideEl(el) {
						// El is already my element's reference
						var myel = el.childNodes[1].childNodes[0].childNodes[1];
						//alert(myel.id);
						if (myel.style.display == "none")
							myel.style.display = "block";
						else
							myel.style.display = "none";
					}
				</script>
			</head>
			<body>
				<div id="root">
					<div id="top"><span>TaskMan-Middleware licensed under GNU-GPL v3</span></div>
					<div id="logdata"><span>Log file for peer: </span>
						<span><xsl:value-of select="/Log/Info/Peer"/></span><br/>
						<span>Log file creation date: </span>
						<span><xsl:value-of select="/Log/Info/CreationDate"/></span>
					</div>
					<div id="log">
						<div style="margin-bottom: 10px">
							<span>Listing all events.</span>
						</div>
						<div>
							<xsl:apply-templates select="/Log/Events"/>
						</div>
					</div>
				</div>
			</body>
		</html>
	</xsl:template>
	<!-- event Event -->
	<xsl:template match="Event">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">Event</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<span class="desc"><xsl:value-of select="Body"/></span>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event WorkflowSubmitted -->
	<xsl:template match="WorkflowSubmitted">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">WorkflowSubmitted</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="Workflow"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event WorkflowEnqueued -->
	<xsl:template match="WorkflowEnqueued">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">WorkflowEnqueued</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="Workflow"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event WorkflowDequeued -->
	<xsl:template match="WorkflowDequeued">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">WorkflowDequeued</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="Workflow"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event TaskSent -->
	<xsl:template match="TaskSent">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">TaskSent</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="Address"/>
						<xsl:apply-templates select="TaskDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event TaskReceived -->
	<xsl:template match="TaskReceived">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">TaskReceived</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="Address"/>
						<xsl:apply-templates select="TaskDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event WorkerDescriptorAdded -->
	<xsl:template match="WorkerDescriptorAdded">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">WorkerDescriptorAdded</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="WorkerDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event WorkerDescriptorUpdated -->
	<xsl:template match="WorkerDescriptorUpdated">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">WorkerDescriptorUpdated</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="WorkerDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event TaskEnqueued -->
	<xsl:template match="TaskEnqueued">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">TaskEnqueued</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="TaskDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event TaskDequeued -->
	<xsl:template match="TaskDequeued">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">TaskDequeued</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="TaskDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event StatusUpdateLoop -->
	<xsl:template match="StatusUpdateLoop">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">StatusUpdateLoop</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<div style="border-bottom:1px solid #cccccc;margin-bottom:5px">
							<div>
								<span class="desc">Showing old worker descriptor:</span>
							</div>
							<div>
								<xsl:apply-templates select="WorkerDescriptor[@flag='old']"/>
							</div>
						</div>
						<div style="border-bottom:1px solid #cccccc;margin-bottom:5px">
							<div>
								<span class="desc">Showing updated worker descriptor:</span>
							</div>
							<div>
								<xsl:apply-templates select="WorkerDescriptor[@flag='new']"/>
							</div>
						</div>
						<div>
							<div>
								<span class="desc">Status changed: 
								<xsl:value-of select="IsStatusChanged"/></span>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event TDCCollectorLoopExec -->
	<xsl:template match="TDCCollectorLoopExec">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">TDCCollectorLoopExec</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<span class="desc">Collected entries: 
						<xsl:value-of select="CollectedEntries"/></span>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event ExecTaskStillNotExecuted -->
	<xsl:template match="ExecTaskStillNotExecuted">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">ExecTaskStillNotExecuted</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<div style="border-bottom:1px solid #cccccc;margin-bottom:5px">
							<div>
								<span class="desc">Showing task descriptor:</span>
							</div>
							<div>
								<xsl:apply-templates select="TaskDescriptor"/>
							</div>
						</div>
						<div>
							<div>
								<span class="desc">Attempt: <xsl:value-of select="Attempt"/> of 
								<xsl:value-of select="Attempts"/></span>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event TaskExecuted -->
	<xsl:template match="TaskExecuted">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">TaskExecuted</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="TaskDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- event WorkerDescriptorSent -->
	<xsl:template match="WorkerDescriptorSent">
		<div id="element" onclick="showHideEl(this)">
			<div style="background-color:#888888;height:3px"></div>
			<div id="elementbody">
				<div id="container">
					<div id="titleel">
						<span>event: <span class="enf">WorkerDescriptorSent</span> - raised at: 
							<span class="enf"><xsl:value-of select="@timestamp"/></span> - 
							from issuer: <span class="enf"><xsl:value-of select="@issuer"/>
							</span></span>
					</div>
					<div style="margin-top:6px">
						<xsl:apply-templates select="WorkerDescriptor"/>
					</div>
				</div>
			</div>
			<div style="background-color:#888888;height:1px"></div>
		</div>
	</xsl:template>
	<!-- Single elements -->
	<!-- Workflow -->
	<xsl:template match="Workflow">
		<div id="innerelement">
			<div style="background-color:#dadada;padding:3px 3px 3px 3px;
			border-bottom:1px solid #999999"><span style="color:#9C0E0E">Workflow</span></div>
			<div style="padding:3px 3px 3px 3px">
				<div>
					<span class="desc">ID of workflow is: <xsl:value-of select="ID"/></span>
				</div>
				<div style="margin:3px 3px 3px 20px;border:1px solid #cccccc;
						padding:5px 5px 5px 5px">
					<div><span class="desc">Listing tasks in workflow:</span></div>
					<div style="margin-top:5px">
						<xsl:apply-templates select="Tasks/TaskDescriptor"/>
					</div>
				</div>
			</div>
		</div>
	</xsl:template>
	<!-- TaskDescriptor -->
	<xsl:template match="TaskDescriptor">
		<div id="innerelement">
			<div style="background-color:#dadada;padding:3px 3px 3px 3px;
			border-bottom:1px solid #999999"><span style="color:#9C0E0E">Task Descriptor</span>
			</div>
			<div style="padding:3px 3px 3px 3px">
				<div>
					<span class="desc">The information about this task descriptor are provided 
					in the following table:</span>
					<table>
						<tr>
							<th>
								<span class="desc">Task id</span>
							</th>
							<th>
								<span class="desc">Task type</span>
							</th>
							<th>
								<span class="desc">Task command</span>
							</th>
						</tr>
						<tr>
							<td>
								<span class="desc"><xsl:value-of select="ID"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="Type"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="Command"/></span>
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</xsl:template>
	<!-- WorkerDescriptor -->
	<xsl:template match="WorkerDescriptor">
		<div id="innerelement">
			<div style="background-color:#dadada;padding:3px 3px 3px 3px;
			border-bottom:1px solid #999999"><span style="color:#9C0E0E">Worker Descriptor</span>
			</div>
			<div style="padding:3px 3px 3px 3px">
				<div>
					<xsl:apply-templates select="Address"/>
					<xsl:apply-templates select="WorkerCapabilities"/>
				</div>
			</div>
		</div>
	</xsl:template>
	<!-- Address -->
	<xsl:template match="Address">
		<div id="innerelement">
			<div style="background-color:#dadada;padding:3px 3px 3px 3px;
			border-bottom:1px solid #999999"><span style="color:#9C0E0E">Address</span>
			</div>
			<div style="padding:3px 3px 3px 3px">
				<div>
					<span class="desc">The information about the address are shown in the following 
					table:</span>
					<table>
						<tr>
							<th>
								<span class="desc">Ip Address</span>
							</th>
							<th>
								<span class="desc">Man2Man Port</span>
							</th>
							<th>
								<span class="desc">W2Disc Port</span>
							</th>
							<th>
								<span class="desc">Man2W Port</span>
							</th>
						</tr>
						<tr>
							<td>
								<span class="desc"><xsl:value-of select="IPAddress"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="TasksPort"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="WDescsPort"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="DataPort"/></span>
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</xsl:template>
	<!-- WorkerCapabilities -->
	<xsl:template match="WorkerCapabilities">
		<div id="innerelement">
			<div style="background-color:#dadada;padding:3px 3px 3px 3px;
			border-bottom:1px solid #999999"><span style="color:#9C0E0E">Worker Capabilities</span>
			</div>
			<div style="padding:3px 3px 3px 3px">
				<div>
					<span class="desc">The information about the worker capabilities are shown 
					in the following table:</span>
					<table>
						<tr>
							<th>
								<span class="desc">Cpu speed (Mhz)</span>
							</th>
							<th>
								<span class="desc">Ram (Mb)</span>
							</th>
							<th>
								<span class="desc">Core(s) num</span>
							</th>
							<th>
								<span class="desc">Cpu(s) num</span>
							</th>
							<th>
								<span class="desc">Distance (hops)</span>
							</th>
							<th>
								<span class="desc">Bandwidth (KHz)</span>
							</th>
						</tr>
						<tr>
							<td>
								<span class="desc"><xsl:value-of select="CpuMhz"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="RamMb"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="CoresNum"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="CpusNum"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="DistanceHops"/></span>
							</td>
							<td>
								<span class="desc"><xsl:value-of select="Bandwidth"/></span>
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</xsl:template>
</xsl:stylesheet>